﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace TestServer {
    [ServiceContract]
    public class TestService {

        [WebGet(UriTemplate = "")]
        public HttpResponseMessage GetRoot(HttpRequestMessage request) {
            var response = new HttpResponseMessage();
           // response.Content = new StringContent("Hello world", Encoding.UTF8, "text/plain");
            response.Content = new StreamContent(this.GetType().Assembly.GetManifestResourceStream(this.GetType(),"Root.xaml"));
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xaml+xml");
            response.Headers.CacheControl = new CacheControlHeaderValue() { NoCache = true};
            return response;
        }

        [WebGet(UriTemplate = "Content")]
        public HttpResponseMessage GetContent(HttpRequestMessage request ) {
            var response = new HttpResponseMessage();
            response.Content = new StringContent("<Textblock Text='Hello, world!' />", Encoding.UTF8 ,"application/vnd.tavis.xaml+xml");
            return response;
        }

        [WebInvoke(UriTemplate = "MessageProcessor", Method ="POST")]
        public HttpResponseMessage PostMessageProcessor(HttpRequestMessage request) {
            var response = new HttpResponseMessage();
            response.Content = request.Content;
            response.StatusCode = HttpStatusCode.OK;
            return response;
        }

    
    }
}
